package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingPlan;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description NursingPlanController
 * @Author shuaijie LI
 * @Date 2024-08-27
 */
@RestController
@RequestMapping("/nursing/plan")
public class NursingPlanController {
    @Autowired
    private NursingPlanService nursingPlanService;

    /**
     * @Description 查询所有
     * @Author shuaijie LI
     * @Date 2024-08-27
     */
    @GetMapping
    public ResponseResult getAll() {
        List<NursingPlan> nursingPlans = nursingPlanService.getAll();
        return ResponseResult.success(nursingPlans);
    }

    /**
     * @Description 分页查询
     * @Author shuaijie LI
     * @Date 2024-08-27
     */
    @ApiOperation(value = "分页查询")
    @GetMapping("/search")
    public ResponseResult<PageResponse<NursingPlanVo>> page(
            @ApiParam(value = "护理项目名称")
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(value = "当前页码")
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @ApiParam(value = "每页显示条数")
            @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
            @ApiParam(value = "状态（0：禁用，1：启用）")
            @RequestParam(value = "status", required = false) Integer status
    ) {
        PageResponse<NursingPlanVo> pageResponse = nursingPlanService.page(name, pageNum, pageSize, status);
        return ResponseResult.success(pageResponse);
    }

    @PostMapping
    public ResponseResult add(@RequestBody NursingProjectDto nursingProjectDto) {

        return ResponseResult.success();
    }
}
